package com.log4j.kafka.utils;

import org.apache.log4j.spi.Filter;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.log4j.varia.LevelRangeFilter;

/**
 * Created by yangshunxing on 2017/5/11.
 */
public class recordLogFilter extends LevelRangeFilter{
    boolean acceptOnMatch = false;
    private int levelMin;
    private int levelMax;

    public boolean isAcceptOnMatch() {
        return acceptOnMatch;
    }

    public void setAcceptOnMatch(boolean acceptOnMatch) {
        this.acceptOnMatch = acceptOnMatch;
    }



    @Override
    public int decide(LoggingEvent loggingEvent) {
        int inputLevel = loggingEvent.getLevel().toInt();
        if(inputLevel>=levelMin && inputLevel <=levelMax){
            return 0;
        }
        return -1;
    }
}
